package com.java_exam.java_exam.Mapper_impl;

import com.java_exam.java_exam.Mapper.AdminMapper;
import com.java_exam.java_exam.entity.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class AdminMapperImpl {
    @Autowired
    AdminMapper adminMapper;

    //添加
    public int AddAdmin(Admin admin)  {
        return adminMapper.insert(admin);
    }
    //根据id删除
    public int DeleteAdminById(int id){
        return adminMapper.deleteById(id);
    }
    //查询所有
    public List<Admin> QueryAllAdmin(){return adminMapper.selectList(null);}
    //根据名字查询
    public List<Admin> QueryByName(String name) {
        Map<String,Object> map = new HashMap<>();
        map.put("admin_name",name);
        List<Admin> adminresult = adminMapper.selectByMap(map);
        System.out.println("现在获取到查询的值\n\n\n\n\n\n");
        adminresult.forEach(System.out::println);
        return adminresult;
    }

}
